﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Apex.Common.MVVM;
using Apex.Script.Models;

namespace Apex.Script.ViewModels
{
    public class SequenceViewModel : CollectionViewModel<Sequence, SceneViewModel, Scene>
    {
        public int ID
        {
            get { return Model.ID; }
            set { Model.ID = value; OnPropertyChanged("ID"); }
        }

        public string Name
        {
            get { return Model.Name; }
            set { Model.Name = value; OnPropertyChanged("Name"); }
        }

        public string Group { get; set; }

        public string TreeDisplayText
        {
            get { return Name; }
        }

        public SequenceViewModel()
            : base()
        {
            Group = "Scenes";
        }

        public SequenceViewModel(Sequence model)
            : base(model)
        {
            Group = "Scenes";
            _items.CollectionChanged -= _items_CollectionChanged;
            foreach (var x in model.Items)
            {
                _items.Add(new SceneViewModel(x));
            }
            _items.CollectionChanged += _items_CollectionChanged;
        }
    }

    public class SequenceGroupViewModel : CollectionViewModel<SequenceGroup, SequenceViewModel, Sequence>
    {
        public int ID
        {
            get { return Model.ID; }
            set { Model.ID = value; OnPropertyChanged("ID"); }
        }

        public string Name
        {
            get { return Model.Name; }
            set { Model.Name = value; OnPropertyChanged("Name"); }
        }

        public string Group { get; set; }

        public string TreeDisplayText
        {
            get { return Name; }
        }

        public SequenceGroupViewModel()
            : base()
        {
            Group = "Sequences";
        }

        public SequenceGroupViewModel(SequenceGroup model)
            : base(model)
        {
            Group = "Sequences";
            _items.CollectionChanged -= _items_CollectionChanged;
            foreach (var x in model.Items)
            {
                _items.Add(new SequenceViewModel(x));
            }
            _items.CollectionChanged += _items_CollectionChanged;
        }
    }
}
